package cn.tradewin.advisor.pages.activiti;

import java.util.List;
import java.util.Map;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;

public class TaskList {


	@Inject
    private RuntimeService runtimeService;
	
	@Inject
	private TaskService taskService;
	
	@Property
	private List<Task> tasks;
	
	@Property
	private Task task;
	
	@Inject
	Logger log;
	
	@SetupRender
	void onPrepareRender() {
		tasks = taskService.createTaskQuery().taskAssignee("kafeitu").list();		
	}

	void onApproved(String taskid) {
		log.debug("++++++++++++++++++++++++++++approved task is : " + taskid);
		Map<String, Object> variables = taskService.getVariables(taskid);
		log.debug(variables.toString());
		taskService.complete(taskid);
	}
}
